package com.ruoyi.web.controller.business;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.domain.vo.MessageStatusVo;
import com.ruoyi.system.domain.vo.ValveVo;
import com.ruoyi.system.service.InitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("前端初始化接口")
@RestController
@RequestMapping("/init")
public class InitController extends BaseController {


    @Autowired
    private InitService initService;

    @ApiOperation("设置自动手动")
    @PostMapping("/setAuto")
    public AjaxResult setAuto(@RequestBody SysConfig sysConfig) {
        return initService.setAuto(sysConfig,getUsername());
    }


    @ApiOperation("初始化获取设备状态")
    @PostMapping("/getAutoAll")
    public AjaxResult getAutoAll() {
        return initService.getAutoAll();
    }


    @ApiOperation("开启或者关闭阀门")
    @PostMapping("/updateAutoAll")
    public AjaxResult updateAutoAll(@RequestBody ValveVo valveVo) {
        return initService.updateAutoAll(valveVo,getUsername());
    }

    @ApiOperation("开启或者关闭泵")
    @PostMapping("/updateAutoPump")
    public AjaxResult updateAutoPump(@RequestBody ValveVo valveVo) {
        return initService.updateAutoPump(valveVo,getUsername());
    }


    @ApiOperation("获取操作记录")
    @PostMapping("/getOperation")
    public AjaxResult getOperation() {
        return initService.getOperation();
    }
    @ApiOperation("获取自动手动状态")
    @PostMapping("/getConfig")
    public AjaxResult getConfig() {
        return initService.getConfig();
    }


    @ApiOperation("确认或者取消报警提示框")
    @PostMapping("/setMessageStatus")
    public AjaxResult setMessageStatus(MessageStatusVo messageStatusVo) {
        return initService.setMessageStatus(messageStatusVo);
    }


}
